package com.sunchen.asc.service.item.repository;

import com.sunchen.asc.service.item.domain.Process;
import com.sunchen.asc.service.item.vo.ProcessVo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;


public interface ProcessRepository extends JpaRepository<Process,Long> {

    @Modifying
    @Query("delete from Process t where t.itemId = ?1")
    void deleteAllByItemId(Long itemId);

    @Query("select new com.sunchen.asc.service.item.vo.ProcessVo(t.id,t.itemId,t.name,t.step,t.limit,t.user,t.standard,t.sendType,t.result,t.standardFlag,t.standardType,t.type,t.sortOrder,t.remark) from Process t where t.itemId = ?1 order by t.sortOrder asc")
    List<ProcessVo> getVosByItemId(Long itemId);
}
